﻿//NorManager - OpenTTD Dedicated server manager
//Copyright (C) 2014 Tomáš Bosek

//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Text;

namespace NorManager
{
    /// <summary>
    /// Specific filter action delegate.
    /// </summary>
    /// <param name="line">Full line contaning pattern</param>
    public delegate void FilterAction(string line);
    /// <summary>
    /// Filter class determines specific behaviour to pattern in output
    /// </summary>
    public class Filter
    {
        /// <summary>
        /// Pattern string.
        /// </summary>
        public string Pattern { get { return pattern; } }
        private string pattern = String.Empty;

        /// <summary>
        /// Response to specific pattern.
        /// </summary>
        public FilterAction Action { get { return action; } }
        private FilterAction action;
        /// <param name="pattern">Pattern string. ex.: "[All]" (pattern will match say commands)</param>
        /// <param name="action">Response to specific pattern.</param>
        public Filter(string pattern, FilterAction action)
        {
            this.pattern = pattern;
            this.action = action;
        }
    }
}
